﻿package com.eitb.plantillas{
	import flash.net.*;
	import flash.text.*;
	import flash.media.*;
	import flash.events.*;
	import flash.display.*;
	import com.eitb.programas.*;
	import com.eitb.cargadores.*;
	import com.eitb.events.ScrollEvent;

	public class PlantillaReproductor extends Sprite implements IVistaPlantilla,IVistaPlantillaReproductor {
		private var cPrograma:IControladorPrograma;
		private var cPlantilla:IControladorPlantilla;
		private var cPlantillaReproductor:IControladorPlantillaReproductor;

		public function PlantillaReproductor():void {
			this.botonPlay.gotoAndStop("reposo");
			this.botonPause.gotoAndStop("reposo");
			this.botonPause.visible = false;
			this.botonAtras.gotoAndStop("reposo");
			this.botonAtras.visible = false;
			this.botonSonido.gotoAndStop("reposo");
			this.botonSonido.visible = false;

			this.scrollRojo.visible = false;
		}
		
		public function initControladorPrograma(cPrograma:IControladorPrograma):void {
			this.cPrograma = cPrograma;
		}
		public function initControladorPlantilla(cPlantilla:IControladorPlantilla):void {
			this.cPlantilla = cPlantilla;
		}

		public function initControladorPlantillaReproductor(cPlantillaReproductor:IControladorPlantillaReproductor):void {
			this.cPlantillaReproductor = cPlantillaReproductor;
		}

		public function initEvents():void {
			this.botonPlay.addEventListener(MouseEvent.CLICK, this.cPlantillaReproductor.clickBotonPlay);
			this.botonPause.addEventListener(MouseEvent.CLICK, this.cPlantillaReproductor.clickBotonPause);
			this.botonAtras.addEventListener(MouseEvent.CLICK, this.cPlantillaReproductor.clickBotonAtras);
			this.botonSonido.addEventListener(MouseEvent.CLICK, this.cPlantillaReproductor.clickBotonSonido);
			this.scrollRojo.addEventListener(ScrollEvent.POINT_SELECTED, this.cPlantillaReproductor.upBotonScroll);
		}
		
		public function setVisible(mostrar:Boolean):void {
			this.visible=mostrar;
		}
		
		// REPRODUCTOR
			public function setBotonPauseVisible(mostrar:Boolean):void{
				this.botonPause.visible = mostrar;
			}
			public function setBotonPlayVisible(mostrar:Boolean):void{
				this.botonPlay.visible = mostrar;
			}
			
			public function setBotonAtrasVisible(mostrar:Boolean):void {
				this.botonAtras.visible = mostrar;
			}
			public function setBotonSonidoVisible(mostrar:Boolean):void {
				this.botonSonido.visible = mostrar;
			}
			
			public function setScrollRojoVisible(mostrar:Boolean):void{
				this.scrollRojo.visible = mostrar;
			}
			public function attachNetStream(netStream:NetStream):void{
				this.video.attachNetStream(netStream);
			}
			public function setTiempoTranscurrido(tTranscurrido:String):void{
				this.tiempoTranscurrido.text = tTranscurrido;
			}
			public function setTiempoTotal(tTotal:String):void {
				this.tiempoTotal.text = tTotal;
			}
			public function dispatchPlayEvent(event:MouseEvent):void {
				this.botonPlay.dispatchEvent(event);
			}
			
			public function dispatchBotonAtrasEvent(event:MouseEvent):void {
				this.botonAtras.dispatchEvent(event);
			}

		// REPRODUCTOR
	}
}